// Copyright (c) 2025, 大连理工大学 (Dalian University of Technology)
//
// Licensed under the Mulan PSL v2.
// You can use this file according to the terms and conditions of the Mulan PSL v2.
// You may obtain a copy of the License at
//
//     http://license.coscl.org.cn/MulanPSL2
//
// THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
// EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. SEE THE MULAN PSL v2
// FOR MORE DETAILS.

/*
 * @Author: Yang qiuyou wangyi168359476@163.com
 * @Date: 2024-07-16 18:39:38
 * @LastEditors: qiulin ql1746365080@gmail.com
 * @LastEditTime: 2024-12-12 15:10:53
 * @FilePath: \SGFEM\Import\NastranBDF\test\Coordinate\CORD2SParserTest.cpp
 */

#include "Import/BDFImport/BulkData/Coordinate/CORD2SParser.h"

#include "gtest/gtest.h"

#include "DBManager/DBServiceFactory.h"
#include "DBManager/IService/Input/Coordinate/ICORD2SService.h"

#include "Import/BDFImport/BDFParserBase.h"
using namespace SG::DBManager;
using namespace SG::Import;
using SG::DataStructure::Common::TOLERANCE;
using namespace SG::DataStructure::FEM;
extern std::shared_ptr<DBServiceFactory> DB_SERVICEFACTORY;
extern std::vector<std::string>          dividedEntryInfo;

class CORD2SParserTest : public ::testing::Test
{
  public:
    static void SetUpTestSuite ()
    {
        DB_SERVICEFACTORY->ClearDatabase ();
    }
};

TEST_F (CORD2SParserTest, ParseEntry1)
{
    //$1234567$1234567$1234567$1234567$1234567$1234567$1234567$1234567$1234567$1234567
    // GTEST_SKIP ();

    std::vector<std::string> Entry = { "CORD2S*  91001                           1499.46         18114.7",
                                       "*        -553.589       19604.175245544818699.8991998611 1050.7878063464",
                                       "*       3205.4115460724711128.9182086802 -17256.45639602",
                                       "*" };

    BDF::divideBulkEntry (Entry, dividedEntryInfo);
    SG::Import::BDF::BULKDATA::ParseCORD2S (DB_SERVICEFACTORY, dividedEntryInfo);

    SG::DataStructure::FEM::CORD2SData data;
    ASSERT_TRUE (DB_SERVICEFACTORY->get<ICORD2SService> ()->FindById (91001, _OUT data)
                 == SG::DataStructure::Common::Status::STATUS_Success);
    ASSERT_TRUE (data.m_id == 91001);
    ASSERT_NEAR (data.m_a1, 1499.46, TOLERANCE);
    ASSERT_NEAR (data.m_a2, 18114.7, TOLERANCE);
    ASSERT_NEAR (data.m_a3, -553.589, TOLERANCE);
    ASSERT_NEAR (data.m_b1, 19604.1752455448, TOLERANCE);
    ASSERT_NEAR (data.m_b2, 18699.8991998611, TOLERANCE);
    ASSERT_NEAR (data.m_b3, 1050.7878063464, TOLERANCE);
    ASSERT_NEAR (data.m_c1, 3205.41154607247, TOLERANCE);
    ASSERT_NEAR (data.m_c2, 11128.9182086802, TOLERANCE);
    ASSERT_NEAR (data.m_c3, -17256.45639602, TOLERANCE);
    // std::cout << "未实现接口\n";
}
